void inttostr(int x, char str[])
{
    int cnt = 0;
    while (x)
    {
        int t = x % 10;
        str[cnt++] = t + '0';
        x /= 10;
    }
    str[cnt] = '\0';
}